
package cn.cxy.exec;
/**
 * @Author 金帮嘉诚
 * @Date 2021-06-09 周三 9:39
 */
public class TestRecursive {
    public static void main(String[] args) {
        int i=factorial(2);
        System.out.println("factorical(2) = " + factorial(7));
    }


    public static int factorial(int n){
        if (n>1){
            return n*factorial(n-1);
        }
        else if(n>=0){
            return 1;
        }
        else{
            return 0;
        }

    }
}

